var app = getApp()
const getQueryString = (url, name) => {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  var r = url.match(reg);
  if (r != null) return unescape(r[2]);
  return null;
}
const getQRCodeOrBarImg = (text, barcodeFormat, width, height) => {
  return new Promise((resolve, reject) => {
    app.post(app.Apis.GET_CODE_IMG, {
      barcodeFormat,
      width,
      height,
      text
    }, result => {
      resolve({
        text,
        type: barcodeFormat,
        url: result.data
      })
    })
  })
}
module.exports = {
  getQueryString,
  getQRCodeOrBarImg
}
